<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html style="overflow:hidden">
<head>
    <title>$!app_name</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<!-- 框架 -->
    <link href="${base}/include/css/msg.css" rel="stylesheet" type="text/css"/>
    <link href="${base}/include/css/default.css" rel="stylesheet" type="text/css"/>
	<script type='text/javascript'>
		var CONTEXTPATH = '${base}';
	</script>
    <script src="${base}/include/js/main.js"></script>
    <script src="${base}/include/js/string.js"></script>
	<!-- 分页  注意顺序 -->
	<link href="${base}/include/css/themes/gray/easyui.css" rel="stylesheet" type="text/css"/> 	
	<script src="${base}/include/js/jquery.easyui.min.js"></script>	
    <!-- 树 -->
    <script type="text/javascript" src="${base}/include/controls/ztree/jquery.ztree.core-3.5.min.js"></script> 
	<link rel="stylesheet" href="${base}/include/controls/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
       <SCRIPT type="text/javascript">
           <!-- 
           var setting = {
               async: {
                   enable: true,
                   url:"${base}/private/sys/role/ajaxroleuser?roleid=$!roleid",
                   autoParam:["id", "name=n", "level=lv"]
               },
               view:{
				    nameIsHTML: true
               }
           };
           function initTree(){
        	    jQuery.fn.zTree.init(jQuery("#treeDemo"), setting);
			}
           function doSave(){
               var ids = [];
        		var arr = $('#dg1').datagrid('getSelections');
        	    if (!arr || arr.length == 0) {
        	        Dialog.alert("请选择用户！");
        	        return false;
        	    }
        	    for(var i=0; i<arr.length; i++){
        	        ids.push(arr[i].id);
        	    }
				$("#checkids").val(ids);
                return true;
           } 
		   function list(unitid){
        	   Page.setValue("SearchUserName","");
			   Page.setValue("unitid",unitid);
        	   jQuery.ajax({
          		 	type: 'POST',
          			url : "${base}/private/sys/user/getuname" ,
          			data : {"unitid":unitid},
          			success : function (res) {        	
          				Page.setValue("unitname",res);
          				loadGrid();
          				 
          			},
          			fail : function(res) {
          				Dialog.alert("系统错误?!");
          			}
          		});
        	    
           }
           function getWidth(percent){
        	   return document.body.clientWidth*percent;
		   }
           function loadGrid(){
		       var SearchUserName=Page.getValue("SearchUserName");
        	   $("#dg1").datagrid({  
        	        width:"auto",
        	   		height:"auto",
        	        nowrap: false,  
        	        striped: true,  
        	        border: true,  
        	        collapsible:false,//是否可折叠的  
        	        fit: true,//自动大小  
        	        url:"${base}/private/sys/role/userlist?unitid="+Page.getValue("unitid"),  
        	        //sortName: 'code',  
        	        //sortOrder: 'desc',  
        	        queryParams:{"SearchUserName":SearchUserName},
        	        remoteSort:false,   
        	        idField:"id",
        	        singleSelect:false,//是否单选  
        	        pagination:true,//分页控件  
        	        rownumbers:true,//行号  
        	        fitColumns: true,//行自适应
        	        pageList:[5,10,15,20,30,40,50],
        	        loadMsg:'数据加载中...',
        	        onDblClickRow:function(rowIndex,row)
        	        {
        	        	//toupdateId(row.id);
        	        },
        	        columns:[[
						{title : '用户名',field : 'loginname',width:getWidth(0.08),align : 'left'},
						{title : '姓名',field : 'realname',width:getWidth(0.08),align : 'left'},
						{title : '帐户状态',field : 'state',align : 'left',
								formatter:function(value,rec,index){
	            					if(rec.state==1)
	            					{
										return '<font color="red">禁用</font>';
	            					}
	            					else
	            					{
	            						return '正常';
	            					}
       					}},
						{title : '职务',field : 'pozition',width:getWidth(0.10),align : 'left'},
						{title : '电子邮件',field : 'email',width:getWidth(0.10),align : 'left'},
						{title : '固定电话',field : 'telephone',width:getWidth(0.10),align : 'left'},
						{title : '手机号码',field : 'mobile',width:getWidth(0.10),align : 'left'}   
        	        ]],
        	        frozenColumns:[[  
        	            {field:"id",checkbox:true}
        	        ]]
        	    });  
        	    //设置分页控件  
        	    var p = $("#dg1").datagrid("getPager");  
        	    $(p).pagination({  
        	        beforePageText: "第",//页数文本框前显示的汉字  
        	        afterPageText: "页    共 {pages} 页",  
        	        displayMsg: "当前显示 {from} - {to} 条记录   共 {total} 条记录",  
        	        onBeforeRefresh:function(){ 
        	           // $(this).pagination('loading'); 
        	             
        	           // $(this).pagination('loaded'); 
        	        } 
        	    });  
           }
		   Page.onLoad(function() { 
			   initTree();
        	   loadGrid(); 
            });
           //-->
       </SCRIPT>

<head>
<body leftmargin="0" topmargin="0">
<table width="100%" border="0" cellspacing="6" cellpadding="0"
       style="border-collapse: separate; border-spacing: 6px;">
    <tr valign="top">
        <td width="180">
        <form name='form1' id="form1" method='post'>
			<input type="hidden" value="" id="para" />
			<input type="hidden" value="" id="id" />
            <input type="hidden" value="$!roleid" id="roleid" name="roleid" />
			<input type="hidden" name="unitid" id="unitid" value="$!unitid">
			<input type="hidden" name="checkids" id="checkids" value="">
            <table width="170" height="100%" border="0" cellspacing="0" cellpadding="6"
                   class="blockTable">
                <tr>
                    <td style="padding:6px;" class="blockTd">
                        <div ztype='_Tree' style='-moz-user-select:none;height:380px;width:160px;' id='tree1' class='treeItemN'>

		         <ul id="treeDemo" class="ztree"></ul>
                    </div>

                    </td>
                </tr>
            </table>
             

        </td>
        <td width="100%" valign="top">
           <table width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: separate; border-spacing: 0;">
    <tr valign="top">
      <td>
	  
        
                                    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="blockTable">
                                      <tr>
                                        <td class="blockTd"><table width="100%" border="0" cellspacing="0" cellpadding="6" >
                                          <tr>
                                            <td valign="middle"><img src="${base}/images/icons/icon021a1.gif" width="20" height="20" />&nbsp;<span id="unitname">所有机构 </span>&nbsp;|&nbsp;用户列表</td>
                                          </tr>
                                          <tr>
                                            <td style="padding:0 8px 4px;">
                                              &nbsp;
                                              <input name="SearchUserName" type="text" id="SearchUserName"
			value="" placeholder="请输入用户名或姓名" style="width:110px">
                                              <input type="button" name="Submitbutton" id="Submitbutton" value="查询"
			onClick="loadGrid()">
                                            </td>
                                          </tr>
                                          <tr>
                                            <td style="padding:0px 5px;"  height="360" >
                                            <table width="100%"  height="100%" id="dg1" cellpadding="2" cellspacing="0" class="dataTable" afterdrag="sortMenu" sortstring="" page="false" size="0"  multiselect="true" autofill="true" scroll="false" lazy="false" cachesize="0">
                                                                                                                                             
                                            </table></td>
                                          </tr>
                                        </table></td>
                                      </tr>
                                    </table>
	   </form>
	  </td>
    </tr>
  </table>
 
        </td>
    </tr>
</table>
</body>
</html>